﻿using Uber.Core.Model;
using Uber.WebUI.Models;

namespace Uber.WebUI.Controllers
{
    using System.Web.Mvc;
    using Core.Service;

    public class ShowController : Controller
    {
        private readonly IShows shows;
        private readonly IAccounts accounts;

        public ShowController(IShows shows, IAccounts accounts)
        {
            this.shows = shows;
            this.accounts = accounts;
        }

        public ActionResult Index(int cid)
        {
            var show = shows.Get(cid);
            if (show == null) return RedirectToAction("Index", "Home");

            return User.IsInRole(The.Nub)
                       ? View(new UserShowDisplay
                                  {
                                      ClientId = cid,
                                      Performer = show.Pro,
                                      //UserId = accounts.GetId(User.Identity.Name),
                                      UserName = User.Identity.Name,
                                      MediaUrl = Gl.MediaUrl()
                                  })
                : View("guest", new GuestShowDisplay
                                    {
                                        ClientId = cid,
                                        Performer = show.Pro,
                                        MediaUrl = Gl.MediaUrl()
                                    });
        }
    }
}